package com.example.property.model

import com.example.common.entity.BaseResultEntity
import com.example.common.model.BaseRepository
import com.example.network.HttpInterceptorType
import com.example.network.TokenInterceptorApiServer
import com.example.property.api.PropertyApiServer
import com.example.property.entity.CarApplyResultEntity
import com.example.property.entity.CarColorResultEntity
import com.example.property.entity.ParkApplyResultEntity
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flowOf
import okhttp3.MultipartBody
import okhttp3.RequestBody
import javax.inject.Inject
/**
 *
 * 车位申请仓库
 * */

class CarApplyRepository @Inject constructor() :BaseRepository<PropertyApiServer>(){

    suspend fun getCarApplyList(): CarApplyResultEntity =(createApiServer(PropertyApiServer::class.java,HttpInterceptorType.TOKEN) as PropertyApiServer).getParkingList()
    suspend fun getParkApplyList( body : RequestBody): ParkApplyResultEntity =(createApiServer(PropertyApiServer::class.java,HttpInterceptorType.TOKEN) as PropertyApiServer).getParkApplyList(body)

    suspend fun getCarColors():CarColorResultEntity=(createApiServer(PropertyApiServer::class.java,HttpInterceptorType.TOKEN) as PropertyApiServer).getCarColor()

    suspend fun uploadCarImageWithFlow(list: MutableList<MultipartBody.Part>): Flow<BaseResultEntity> {
        var resultEntity = (createApiServer(PropertyApiServer::class.java, HttpInterceptorType.UPLOAD) as PropertyApiServer).uploadCarImages(list)
        return flowOf(resultEntity)
    }
    suspend fun uploadCarImage(list: MutableList<MultipartBody.Part>): BaseResultEntity =(createApiServer(PropertyApiServer::class.java,HttpInterceptorType.UPLOAD) as PropertyApiServer).uploadCarImages(list)

}